import request from '@/utils/request';

/**
 * 树结构获取菜单
 */
export function getMenuTree() {
  return request({
    url: '/v1/user/menus/tree',
    method: 'get'
  });
}

/**
 * 获取导航菜单
 */
export function getNav() {
  return request({
    url: '/v1/user/nav',
    method: 'get'
  });
}

/**
 * 删除菜单
 */
export function MenuDelFunC(id) {
  return request({
    url: '/v1/menus/' + id,
    method: 'delete'
  });
}

/**
 * 增加菜单
 */
export function MenuAddFunC(icon, name, orderNum, pidPath, pid, url) {
  return request({
    url: '/v1/menus',
    method: 'post',
    data: {
      icon,
      name,
      orderNum,
      pidPath,
      pid,
      url
    }
  });
}

/**
 * 修改菜单
 */
export function MenuChangeFunC(id, icon, name, orderNum, pidPath, pid, url) {
  return request({
    url: '/v1/menus/' + id,
    method: 'put',
    data: {
      id,
      icon,
      name,
      orderNum,
      pidPath,
      pid,
      url
    }
  });
}

/**
 * 菜单按钮管理 增加按钮
 */
export function buttonAddBtnFunC(code, menuId, name) {
  return request({
    url: '/v1/menu-buttons',
    method: 'post',
    data: {
      code,
      menuId,
      name
    }
  });
}

/**
 * 菜单按钮管理 修改按钮
 */
export function buttonChangeBtnFunC(id, code, name) {
  return request({
    url: '/v1/menu-buttons/' + id,
    method: 'put',
    data: {
      id,
      code,
      name
    }
  });
}

/**
 * 菜单按钮管理 删除按钮
 */
export function buttonDelBtnFunC(id) {
  return request({
    url: '/v1/menu-buttons/' + id,
    method: 'delete'
  });
}

/**
 * 根据菜单ID获取按钮
 */
export function getButtonByIdFunC(menuId) {
  return request({
    url: '/v1/menus/' + menuId + '/menu-buttons',
    method: 'get'
  });
}
